package com.yit.cn;

import java.awt.*;

/**
 * Created by zhangyanfei on 2019/4/21.
 *
 * @author zhangyanfei
 * @date 2019/04/21
 */
public class PlanC extends AbstractPlan {
    private SchedulingContext schedulingContext;

    /**
     * 1.6
     *
     * 0.08
     */
    Pilot normalBpilot = new Pilot("normalB", 1.6, 0.08);

    public PlanC(SchedulingContext schedulingContext) {
        super(schedulingContext);
        this.schedulingContext = schedulingContext;

    }

    public Pilot getPilot() {
        schedulingContext.isFly = false;
        schedulingContext.setNormalACanFly(true);
        schedulingContext.setNormalBCanFly(false);
        //加班
        if (schedulingContext.grandTotalDaysOfA > SchedulingContext.threshold) {
            schedulingContext.restOfA += 1;
        }
        return normalBpilot;
    }

    public boolean condition() {
        if (!schedulingContext.isFly) {
            return false;
        }
        return schedulingContext.isNormalBCanFly();
    }

    public String getSFCofDay() {
        if (schedulingContext.getAirplaneModel().equalsIgnoreCase("X")) {
            return "消耗油量：" + schedulingContext.getLoad() *schedulingContext.getDistance() * normalBpilot.getSfc() + "吨油量;";
        } else {
            return "消耗油量：" +schedulingContext.getLoad() * schedulingContext.getDistance() * 0.07 + "吨油量;";
        }

    }

    public String getElapsedTime() {
        if (schedulingContext.getAirplaneModel().equalsIgnoreCase("X")) {
            return "飞行时间：" + schedulingContext.getDistance() / normalBpilot.getFlySpeed() + "h;";
        } else {
            return "飞行时间：" + schedulingContext.getDistance() / (1.15 * normalBpilot.getFlySpeed()) + "h;";
        }

    }

}
